package com.yvan.periscope.domain;

import java.util.ArrayList;
import java.util.List;

/**
 * @Author：BluesZhao
 * @Description：直方图数据实体类
 * @Date： Create in 下午3:12 2018/8/16
 */
public class HistogramBean {
    //标题集合
    private List<String> titles = new ArrayList<>();
    //直方图数据集合
    private List<Object> histogramDatas = new ArrayList<>();
    //横坐标title
    private String xAxisTitle;
    //纵坐标title
    private String yAxisTitle;

    public String getxAxisTitle() {
        return xAxisTitle;
    }

    public void setxAxisTitle(String xAxisTitle) {
        this.xAxisTitle = xAxisTitle;
    }

    public String getyAxisTitle() {
        return yAxisTitle;
    }

    public void setyAxisTitle(String yAxisTitle) {
        this.yAxisTitle = yAxisTitle;
    }

    public List<String> getTitles() {
        return titles;
    }

    public void setTitles(List<String> titles) {
        this.titles = titles;
    }

    public List<Object> getHistogramDatas() {
        return histogramDatas;
    }

    public void setHistogramDatas(List<Object> histogramDatas) {
        this.histogramDatas = histogramDatas;
    }

    /**
     * 向直方图对象中添加一个标题
     * @param title
     */
    public void addTitle(String title){
        this.titles.add(title);
    }

    /**
     * 向直方图对象里面添加一个title数组
     * @param titleArray
     */
    public void addTitleArray(long[] titleArray){
        if(titleArray == null || titleArray.length == 0){
            return;
        }
        for (int i=0;i<titleArray.length;i++) {
            if(i == 0){
                this.titles.add("0-"+titleArray[i]);
            }else {
                this.titles.add(titleArray[i-1]+"-"+titleArray[i]);
            }
        }
        this.titles.add(titleArray[titleArray.length - 1] + "以上");
    }

    /**
     * 向直方图中添加一条数据
     * @param data
     */
    public void addData(Object data){
        this.histogramDatas.add(data);
    }
}
